package com.ruoyi.basedata.service.impl;

import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basedata.mapper.ElectricityAreaZoneJoinMapper;
import com.ruoyi.basedata.domain.ElectricityAreaZoneJoin;
import com.ruoyi.basedata.service.IElectricityAreaZoneJoinService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
/**
 * 分区关联-电、水关联Service业务层处理
 *
 * @author gdqt
 * @date 2025-03-06
 */
@Service
public class ElectricityAreaZoneJoinServiceImpl extends ServiceImpl<ElectricityAreaZoneJoinMapper, ElectricityAreaZoneJoin> implements IElectricityAreaZoneJoinService
{
    @Autowired
    private ElectricityAreaZoneJoinMapper electricityAreaZoneJoinMapper;

    /**
     * 查询分区关联-电、水关联
     *
     * @param id 分区关联-电、水关联主键
     * @return 分区关联-电、水关联
     */
    @Override
    public ElectricityAreaZoneJoin selectElectricityAreaZoneJoinById(Long id)
    {

        return electricityAreaZoneJoinMapper.selectById(id);
    }

    /**
     * 查询分区关联-电、水关联列表
     *
     * @param electricityAreaZoneJoin 分区关联-电、水关联
     * @return 分区关联-电、水关联
     */
    @Override
    public List<ElectricityAreaZoneJoin> selectElectricityAreaZoneJoinList(ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        LambdaQueryWrapper<ElectricityAreaZoneJoin> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getTenantId())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getTenantId,electricityAreaZoneJoin.getTenantId());
        }
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getAreaId())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getAreaId,electricityAreaZoneJoin.getAreaId());
        }
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getAreaName())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getAreaName,electricityAreaZoneJoin.getAreaName());
        }
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getTerminalId())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getTerminalId,electricityAreaZoneJoin.getTerminalId());
        }
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getTerminalName())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getTerminalName,electricityAreaZoneJoin.getTerminalName());
        }
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getUsed())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getUsed,electricityAreaZoneJoin.getUsed());
        }
        if(electricityAreaZoneJoin.getHookType() != null){
            queryWrapper.eq(ElectricityAreaZoneJoin::getHookType,electricityAreaZoneJoin.getHookType());
        }
        if(electricityAreaZoneJoin.getTerminalMark() != null){
            queryWrapper.eq(ElectricityAreaZoneJoin::getTerminalMark,electricityAreaZoneJoin.getTerminalMark());
        }
        if(StringUtils.isEmpty(electricityAreaZoneJoin.getLocationNb())){
            queryWrapper.eq(ElectricityAreaZoneJoin::getLocationNb,electricityAreaZoneJoin.getLocationNb());
        }
        if(electricityAreaZoneJoin.getDownTime() != null){
            queryWrapper.eq(ElectricityAreaZoneJoin::getDownTime,electricityAreaZoneJoin.getDownTime());
        }
        return electricityAreaZoneJoinMapper.selectList(queryWrapper);
    }

    /**
     * 新增分区关联-电、水关联
     *
     * @param electricityAreaZoneJoin 分区关联-电、水关联
     * @return 结果
     */
    @Override
    public int insertElectricityAreaZoneJoin(ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        return electricityAreaZoneJoinMapper.insert(electricityAreaZoneJoin);
    }


    /**
     * 修改分区关联-电、水关联
     *
     * @param electricityAreaZoneJoin 分区关联-电、水关联
     * @return 结果
     */
    @Override
    public int updateElectricityAreaZoneJoin(ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        return electricityAreaZoneJoinMapper.updateById(electricityAreaZoneJoin);
    }

    /**
     * 批量删除分区关联-电、水关联
     *
     * @param ids 需要删除的分区关联-电、水关联主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteElectricityAreaZoneJoinByIds(Long[] ids)
    {
        return electricityAreaZoneJoinMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除分区关联-电、水关联信息
     *
     * @param id 分区关联-电、水关联主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteElectricityAreaZoneJoinById(Long id)
    {
        return electricityAreaZoneJoinMapper.deleteById(id);
    }
}
